package com.bby.admin.controller;

import cn.hutool.json.JSONUtil;
import com.bby.common.model.RunningStatus;
import com.bby.common.utils.BBYUtils;
import com.bby.common.utils.R;
import com.bby.common.utils.SystemMonitor;
import org.springframework.web.bind.annotation.*;


/**
 * 服务监控
 */
@RestController
@RequestMapping("admin/monitor")
public class MonitorController {
    @GetMapping("{serve}")
    R disk(@PathVariable String serve,@RequestParam(defaultValue = "false") boolean info){
        if (BBYUtils.isEmpty(serve)){
            return R.error("参数错误！");
        }
        RunningStatus status = null;
        switch (serve){
            case "monitor": status = SystemMonitor.getRunningStatus(true);break;
            case "disk":break;

        }
        return R.ok(status);
    }

    public static void main(String[] args) throws InterruptedException {
        int i=10;
        while(i-->0) {
            Thread.sleep(1111);
            String s = JSONUtil.parse(SystemMonitor.getRunningStatus(true)).toStringPretty();
            System.out.println(s);
        }
    }
}
